<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
function showData(cardno) {
	xmlHttp = GetXmlHttpObject()
	var url = "studentsearchreturn.jsp";
	url = url + "?cardno=" + cardno;
	xmlHttp.onreadystatechange = stateChanged
	xmlHttp.open("GET", url, true)
	xmlHttp.send(null)
}
function stateChanged() {
	if (xmlHttp.readyState ==4 || xmlHttp.readyState == "complete") {
		var showdata = xmlHttp.responseText;
		var strar = showdata.split(":");
		if (strar.length > 1) {
			var strname = strar[1];
			document.getElementById("studentname").value = strar[2];
			document.getElementById("collegename").value = strar[3];
			document.getElementById("sex").value = strar[4];
			document.getElementById("course").value = strar[5];
			document.getElementById("branch").value = strar[6];
			document.getElementById("year").value = strar[7];
			document.getElementById("address").value = strar[8];
			document.getElementById("city").value = strar[9];
			document.getElementById("zip").value = strar[10];
			document.getElementById("email").value = strar[11];
			document.getElementById("mobile").value = strar[12];
			
		}
	}
}
function GetXmlHttpObject() {
	var xmlHttp = null;
	try {
		xmlHttp = new XMLHttpRequest();
	} catch (e) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
</script>
</head>
<body style="background-color: grey">
<fieldset>
			<legend align="top">
				<h2 style="color: red">Card Search</h2>
			</legend>
<center>
		
		<table>
			<tr>
				<td align="left">Library CardNo:</td>
				<td><input type="text" name="cardno" id="cardno" onkeyup="showData(this.value);" value="">
				</td>
			</tr>
			<tr>
				<td align="left">Student Name:</td>
				<td><input type="text" name="studentname"  id="studentname" value="">
				</td>
			</tr>
			<tr>
				<td align="left">College Name:</td>
				<td><input type="text" name="collegename" id="collegename" value=""></td>
			</tr>
			<tr>
			<td align="left">Sex</td>
			<td><input type="text" name="sex"  id="sex" value=""></td>
			</tr>
			<tr>
				<td align="left">Course</td>
				<td><input type="text"  id="course" name="course" value=""></td>
			</tr>
			<tr>
			<td align="left">Branch</td>
			<td><input type="text" name="branch"  id="branch" value=""></td>
			</tr>
			
			<tr>
			<td align="left">Year</td>
				<td><input type="text" id="year" name="year" value=""></td>
			</tr>
			<tr>
				<td align="left">Address</td>
				<td><input type="text" id="address" name="address" value=""></td>
			</tr>
			<tr>
				<td align="left">City</td>
				<td><input type="text" id="city" name="city" value=""></td>
			</tr>
			<tr>
				<td align="left">Zip Code</td>
				<td><input type="text" id="zip" name="zip" value=""></td>
			</tr>
			<tr>
				<td align="left">Email</td>
				<td><input type="text" id="email" name="email" value=""></td>
			</tr>
			<tr>
				<td align="left">Mobile</td>
				<td><input type="text" id="mobile" name="mobile" value=""></td>
			</tr>
			
		</table>


	</center>
</fieldset>
